<%@ page language="java" import="java.util.*,com.ovt.util.Page,com.ovt.entity.*,com.ovt.biz.*,com.ovt.biz.impl.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>用户列表</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script>
	function orderFunction() {
		alert("aaa");
	}
	</script>
  </head>
  
  <body>
  
        <form action="DatabaseSearch" method="post">
    		<td>输入搜索词 <input type="text" name="keyWord"></td>
    		<td><input type="submit" value="so easy" ></td>
        </form>
    <hr>
    
    <form action="servlet/DatabaseProcess" method="post">
   	 功能列表 : <a href="servlet/DatabaseProcess?choose=1&subchoose1=0">默认排序</a>
   	 		<a href="servlet/DatabaseProcess?choose=1&subchoose1=1">按价格降序排序</a>
   	 		<a href="servlet/DatabaseProcess?choose=1&subchoose1=2">按价格升序排序</a>
   	 价格区间<input  style="width:45px" type="text" name="minprice">-<input style="width:45px" type="text" name="maxprice">
   	 <input type="submit" value="Go" >
   	 </form>
   	 

   	 
   	 <%
      	String temp = null;
      	String keyWord = (String) request.getSession().getAttribute("keyword");   	
     %>
     <%
	     int pageIndex = 1;//获得当前页数
	     String orderby = "";
	     String ordertype = "asc";
	     if(request.getParameter("pageIndex") != null){
	         pageIndex = Integer.parseInt(request.getParameter("pageIndex").toString());
	     }
	     Page pages=new Page();
	     pages.setCurrPageNo(pageIndex);    //设置当前页面
	     pages.setPageSize(5);    //设置每页条数
	     UserBiz userBiz=new UserBizImpl();
	     int totalCount = userBiz.getUserListCount(keyWord);
	     pages.setTotalCount(totalCount);
	     List<User> list = userBiz.getUserList(keyWord,pages);
     %>
   	 
      <div>
      <h2 style="float: left;margin-top: 0;">用户列表</h2>
      <a href="addUser.jsp" style="float: right;">添加用户</a>
      </div>
      <div style="clear: both;">
         <table border="1" cellpadding="0" cellspacing="0">
         <tr>
    	       <td>用户ID</td>
    	       <td>用户名</td>   	       
    	       <td>密码</td>
    	       <td>操作</td>
    	   </tr>
       <%
    		int totalpages=pages.getTotalPageCount();  //总页数
    		for(User user:list){
       %>
    	   <tr>
    	       <td><%=user.getUid()%></td>
    	       <td><%=user.getUname() %></td>
    	       <td><%=user.getUpwd()%></td>
    	       <td><a>编辑</a>&nbsp;&nbsp;<a>删除</a></td>
    	   </tr>	
    	<%
    	     }
    	 %>
    	  </table> 
    	 当前页数：[<%=pageIndex%>/<%=totalpages%>]
    	 <%
   			 if(pageIndex > 1){		//控制页面显示风格
		 %>   
   			 <a href="index.jsp?pageIndex=1">首页</a>&nbsp;
    		 <a href="index.jsp?pageIndex=<%= pageIndex -1%>">上一页</a>
		<% }
    	   if(pageIndex < totalpages){	//控制页面显示风格
		%>
    		<a href="index.jsp?pageIndex=<%= pageIndex +1%>">下一页</a>
    		<a href="index.jsp?pageIndex=<%=totalpages%>">末页</a> 
		<%}
     %>   
     </div>
  </body>
</html>
